package cn.edu.csust.tysp.backend.service.impl;

import cn.edu.csust.tysp.backend.dao.UsersMapper;
import cn.edu.csust.tysp.backend.domain.Users;
import cn.edu.csust.tysp.backend.domain.UsersExample;
import cn.edu.csust.tysp.backend.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName: UserServiceImpl
 * @Author: XijiaoZheng
 * @E-mail: 2516299639@qq.com
 * @Date: 2021/5/9 11:25
 * @Version: V1.0
 * @Description: 对该类的描述
 */

@Service
public class UserServiceImpl implements UserService {


    @Autowired
    UsersMapper usersMapper;
    @Override
    public boolean findbyname(String username) {
        UsersExample example = new UsersExample();
        UsersExample.Criteria criteria = example.createCriteria();
        criteria.andUsernameEqualTo(username);
        long count = usersMapper.countByExample(example);
        return count != 0;
        //相当于：select count(*) from user where username='wyw'
    }

    @Override
    public Users selectPassword(String username, String password) {
        return usersMapper.selectByUsername(username,password);
    }

    @Override
    public int insert(Users users) {
        return usersMapper.insertSelective(users);
    }
}
